package cn.stylefeng.qz.core.util;

import org.apache.commons.lang3.StringUtils;

/**
 * @description 
 * @author qinj
 * @date 2018/11/15 12:00
 */
public class StrUtil {

    /**
     * @description 替换字符串
     * @author qinj
     * @since 2018/11/15 12:01
     * @@param orgin     原始字符串
     * @param startLen   头长度
     * @param endLen     尾长度
     * @param replaceStr 要替换的字符串
     * @return 如果长度不满足，返回原始字符串
     */
    public static String replaceStr(String orgin, int startLen, int endLen, String replaceStr) {
        if(StringUtils.isBlank(orgin))
            return orgin;
        if(startLen + endLen > orgin.length())
            return orgin;
        String newStr = orgin.substring(0, startLen) + replaceStr + orgin.substring(orgin.length() - endLen, orgin.length());
        return newStr;
    }

}
